<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.ddz.model.LoginMessage" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/21
  Time: 19:54
  To change this template use File | Settings | File Templates.
--%>
<html>
<head>
  <title>注册</title>
  <link rel="stylesheet" href="./css/register.css">
</head>
<body>
<%
  if(request.getAttribute("regMessage")!=null){
    LoginMessage loginMessage = (LoginMessage)request.getAttribute("regMessage");
    request.setAttribute("Status",loginMessage.getStatus());
    request.setAttribute("Msg",loginMessage.getMsg());
    request.setAttribute("return_json",loginMessage.getJsonObject());
  }
%>
<%--注册表单--%>
<div class="register-container">
  <h2>用户注册</h2>
  <form action="./register" id="registerform" method="post">
    <label for="nickname">昵称：</label>
    <input type="text" name="nickname" id="nickname" value="${return_json.getString("nickname")}"> <br>
    <label for="uid">账号：</label>
    <input type="text" name="uid" id="uid" value="${return_json.getString("userID")}"> <br>
    <label for="upwd">密码：</label>
    <input type="password" name="upwd" id="upwd" autocomplete="new-password"> <br>
    <label for="reupwd">再次输入密码：</label>
    <input type="password" name="reupwd" id="reupwd"> <br>
    <label for="inviteCode">邀请码：</label>
    <input type="text" name="inviteCode" id="inviteCode"> <br>
    <span id="msg" class="error-msg">${Msg}</span> <br>
    <button type="button" id="regbutton">确认</button>
  </form>
</div>

<%--如果注册成功就跳转--%>
<c:if test="${Status == 200}">
  <script>
    var msg = "<%= request.getAttribute("Msg")%>";
    alert(msg);
    window.location.href = "login.jsp";
  </script>
</c:if>

<script type="text/javascript" src="./js/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="./js/register.js"></script>
</body>
</html>